<?php defined('ByShopWWI') or exit('Access Invalid!');?>

<div class="tabmenu">
    <?php include template('layout/submenu');?>
</div>
<div class="ncsc-form-default">

  <form method="post" action="index.php?act=menu_1018&op=add_order" id="callcenter_form" class="ncs-message">
    <input type="hidden" name="form_submit" value="ok" />
	<div class="ncsc-form-default w400 warp-all">
	<!--
			<dl>
                <dt class="w80">订单号：</dt>
                <dd class="w300"><span class="num">3</span></dd>
            </dl>-->
            <dl>
                <dt class="w80">买&nbsp;家：</dt>
                <dd class="w300"><input type="text" class="text" id="goods_amount" name="buyer" value=""></dd>
            </dl>
            <dl>
                <dt class="w80"><font class="red">*</font>手机号码：</dt>
                <dd class="w300"><input type="text" class="text" name="phone" value=""></dd>
            </dl>
            <dl>
                <dt class="w80"><font class="red">*</font>商品选择：</dt>
                <dd class="w300">
				<input type="hidden" class="text" name="goods_name" value=""/>
				<input type="hidden" class="text" name="goods_price" value=""/>
					<select name="goods_name_show" id="">
						<option value="">请选择</option><!--这行不要删，下面保持数据格式，计算程序才能运行-->
						<option value="">银大佛 / 1500.00 ￥</option>
						<option value="">千足银 / 1999.00 ￥</option>
					</select>
                </dd>
            </dl>
		    <dl>
			  <dt class="w80"><font class="red">*</font>发货状态：</dt>
			  <dd class="w300">
				<select name="goods_state" >
					<option value="0">未发货</option>
					<option value="1">已发货</option>
				</select>
			  </dd>
		    </dl>
            <dl>
                <dt class="w80">数量：</dt>
                <dd class="w300">
                    <input type="text" class="text" id="goods_amount" name="count"  value="1">
                </dd>
            </dl>
            <dl>
                <dt class="w80">订单金额：</dt>
                <dd class="w300">
                    <input type="text" class="text" id="goods_amount" name="price" value="">
                </dd>
            </dl>
	</div>
    <div class="bottom">
	<div class="alert-error">警告：未填正确写买家手机号码、选择商品，无法提交表单!</div>
      <label class="submit-border"><input type="submit" class="submit" value="<?php echo $lang['nc_common_button_submit'];?>" /></label>
    </div>
  </form>
</div>
<script>
$(function(){
	
var check1=false;
submit_check(false)
$("input[name=phone]").bind('input propertychange',function(){
	get_p()
})
$("select[name=goods_name_show]").bind('change',function(){
	get_p()
})

$("input[name=count]").bind('input propertychange',function(){
	get_p()
})

$("input[name=count]").change(function(){
	if($("input[name=count]").val().length<1){
		$("input[name=count]").val(1)
		get_p()
	}
})

function get_p(){
	
	var p = $("select[name=goods_name_show]").find("option:selected")
	var n = $("input[name=count]").val()
	if(n.length>0){
		if (n!=null && n!="" && isNaN(n)){
			var n = 1
			$("input[name=count]").val(n)
		}
	
		if(p.index()!=0){
			p = p.text().split("/")
			var k = p
			p = p[1].match(/[0-9].*.[0-9]/g);
			$("input[name=goods_price]").val(p)

			$("input[name=price]").val(toDecimal2(p*n))

			$("input[name=goods_name]").val(k[0])

			
		}
	}
	var phone = $("input[name=phone]").val()
	
	if(phone.length>0){
		if(checkPhone(phone)){
			check1=true;
		}else{
			check1=false;
		}
	}

	var nn = $("input[name=goods_name]").val()
	if(nn.length>0 && check1){
		submit_check(true)
	}else{
		submit_check(false)
	}

	
}

function submit_check(boo){


	if(boo){
		$("input[type=submit]").removeAttr("disabled")
		$(".alert-error").hide()
	}else{
		$("input[type=submit]").attr("disabled","disabled")
		$(".alert-error").show()
		
	}
}

function toDecimal2(x) { 
      var f = parseFloat(x); 
      if (isNaN(f)) { 
        return false; 
      } 
      var f = Math.round(x*100)/100; 
      var s = f.toString(); 
      var rs = s.indexOf('.'); 
      if (rs < 0) { 
        rs = s.length; 
        s += '.'; 
      } 
      while (s.length <= rs + 2) { 
        s += '0'; 
      } 
      return s; 
}
 
function checkPhone(phone){
    if(!(/^1[34578]\d{9}$/.test(phone))){  
        return false; 
    }
	return true;
}

})


</script>